package com.sf.asp.util;

import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;

/**
 * 时间类工具插件
 */
public class DateUtilBase {

    public static final String TIME_STANDARD = "yyyy-MM-dd HH:mm:ss";

    /**
     * 时间戳转string
     * @param timestamp 时间戳
     * @param format 转换格式
     * @return 格式化成string
     */
    public static  String  timestampToString(Long timestamp,String format){
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern(format);
        return formatter.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneId.systemDefault()));
    }
}
